FileRead, buffer, UnitTest_substitutions.txt
Text1 := buffer
Gosub, BtnConvert

Gui, Add, Edit, x12 y10 w440 h380 vText1, %buffer%
Gui, Add, Edit, x462 y10 w470 h380 vText2, %Text2%
Gui, Add, Button, x12 y390 w100 h30 gBtnConvert, &Convert
Gui, Add, Button, x122 y390 w110 h30 gBtnReload, &Reload

; Generated using SmartGUI Creator 4.0
Gui, Show, x234 y447 h450 w949, Unit Test of substuitions!
Gosub, BtnConvert
#include Capture2Text_BackEnd.ahk
OnExit, SaveText
Return

GuiClose:
ExitApp

BtnReload:
;    Gosub, SaveText
    Reload

BtnConvert:
    Gui, SubMit, NoHide
    text2 =
    Loop, Parse, Text1, `n, `r
    {
        Text3 := performsubstitutions(A_LoopField)
;        Text3 := performsubstitutions(Text3)
;        outputdebug % Text3
        text2 .= text3
        if (A_Index > 20) {
            break
        }
        text2 .= "`r`n"
    }
    GuiControl, , Text2, %Text2%
return

SaveText:
    FileDelete, UnitTest_substitutions.txt
    FileAppend, %Text1%, UnitTest_substitutions.txt
ExitApp
